#!/bin/sh
#

# PROVIDE: shairport_sync
# REQUIRE: FILESYSTEMS DAEMON hostname avahi_daemon

. /etc/rc.subr

name="shairport_sync"
rcvar="shairport_sync_enable"

# NOTE the difference between the service name shairport_sync and the application and script file names shairport-sync.
# This seems to be necessary in FreeBSD, as the startup system doesn't seem to like dashes ("-") in service names.

pidfile="/var/run/shairport-sync.pid"
apptodaemonise="/usr/local/bin/shairport-sync --log-to-syslog"

command="/usr/sbin/daemon"
# -S log to syslog; -P store the supervisor PID; -u to specify the user to run the service under
command_args="-u shairport-sync -S -T shairport-sync -P ${pidfile} ${apptodaemonise}"

load_rc_config $name
run_rc_command "$1"

